<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class tire_journal_list extends Page
{
       public $lblPlate = null;
       public $Label49 = null;
       public $lblmodel = null;
       public $Label43 = null;
       public $lblmake = null;
       public $Label41 = null;
       public $lblyr = null;
       public $lblyear = null;
       public $lblVeh = null;
       public $Label48 = null;
       public $imgBack = null;
       public $Image2 = null;
       public $JTSiteTheme1 = null;
       public $hiddenVehId = null;
       public $imgMount = null;
       public $JTTireJournal = null;
       function imgMountJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgMount'].src="image/mount_dis3.png"
       <?php

       }

       function imgMountJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgMount'].src="image/mount_dis2.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgMountClick($sender, $params)
       {
       redirect('manage_tires.php?vin='.$this->hiddenVehId->getValue());


       }


       function JTTireJournalShow($sender, $params)
       {
       $jou_arr = array();
       $query_journal = "SELECT tire_id, location, description, axle, wheel, tread, date, comments FROM tire_srvcejournal_tbl WHERE vehicle_id='".$this->hiddenVehId->getValue()."' ORDER BY journal_id  DESC";
       $result_journal = mysql_query($query_journal) or die('LIST JOURNAL '.mysql_error());

       while($row_journal = mysql_fetch_array($result_journal))
       {

        $tire_id = $row_journal['tire_id'];

        $query_tire = "SELECT * FROM tire_inventory_tbl WHERE tire_id='".$tire_id."'";
        $result_tire = mysql_query($query_tire) or die('select tire'.mysql_error());
        $row_tire = mysql_fetch_array($result_tire);

        $jou_arr[] = array(
        'Date'=> $row_journal['date'],
        'Description'=> $row_journal['description'],
        'Brand'=> $row_tire['manufacturer'],
        'Position'=> $row_journal['location'],
        'Remarks'=> $row_journal['comments']
        );
       }
       $this->JTTireJournal->setCellData($jou_arr);


       }

       function tire_journal_listCreate($sender, $params)
       {
       $veh_id = $_GET['veh'];
       if(isset($veh_id))
       $this->hiddenVehId->setValue($veh_id);


        $company_id = $_SESSION['company_id'];
        $result_vin = mysql_query("select VIN, year, manufacturer_name, model_name, veh_num from vehicle_tbl where company_id='".$company_id."' AND vehicle_id ='".$this->hiddenVehId->getValue()."'") or die('SELECT VIN'.mysql_error());
        $row_vin = mysql_fetch_array($result_vin);
        $this->lblVeh->Caption=$row_vin['VIN'];
        $this->lblyr->Caption=$row_vin['year'];
        $this->lblmake->Caption=$row_vin['manufacturer_name'];
        $this->lblmodel->Caption=$row_vin['model_name'];
        $this->lblPlate->Caption=$row_vin['veh_num'];

       $this->imgBack->setLink('vehicle_list.php?company_id='.$_SESSION['company_id']);
       $this->imgMount->setLink('manage_tires.php?vin='.$this->hiddenVehId->getValue());
       }
}

global $application;

global $tire_journal_list;

//Creates the form
$tire_journal_list=new tire_journal_list($application);

//Read from resource file
$tire_journal_list->loadResource(__FILE__);

//Shows the form
$tire_journal_list->show();

?>